package com.bupt.liutong.admin.groupon.quartz;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

import org.apache.http.client.ClientProtocolException;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import com.bupt.liutong.admin.groupon.dto.Website;

public class GetDianPingInfo implements GetGrouponInfo {

	public void execute(Website website) {
		SAXReader grouponReader = new SAXReader();
		Document grouponDoc;
		try {
			grouponDoc = grouponReader.read(new URL(
					"http://t.dianping.com/api.xml"));
		} catch (MalformedURLException e) {
			e.printStackTrace();
			return;
		} catch (DocumentException e) {
			e.printStackTrace();
			return;
		}
		Element grouponRoot = grouponDoc.getRootElement();
		List<Element> grouponList = grouponRoot.selectNodes("//url");
		for (Element groupon : grouponList) {
			System.out.println(groupon
					.selectSingleNode("data/display/city").getText());
		}
	}
	
	public static void main(String[] args) throws ClientProtocolException,
			IOException {
		try {
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
